<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="sw">
        <!-- 滑动条 -->
        <input id="num" type="range" min="1" max="100" value="3" step="1">
        <div id="tip">

        </div>
        <img id="img1" src="img/R-C.jpg" alt="404">
    </div>
    <script>
        //先获取拖动元素对象，并保存在变量a中
        var a = document.getElementById("num");
        //绑定对象元素的值改变事件
        a.onchange = function(){
            //获取显示内容的div对象元素，并保存在变量b中
            var b = document.getElementById("tip");
            //将拖动时改变的值赋值给显示的div元素
            b.innerText=a.value;
            //根据不同的值在控制台显示不一样的内容
            switch(a.value){
                case "1":
                    console.log("今天天气很好");
                    break;
                case "2":
                    console.log("明天天气很好");
                    break;
                case "100":
                    //图片隐藏
                    document.getElementById("img1").style.display = "none";
                    break;
                default:
                    if(document.getElementById("img1").style.display=="none"){
                        document.getElementById("img1").style.display = "";
                    }
                    break;
            }
            var s=0;
            for(i=0;i<=100;i++){
                s+=i;
            }
            console.log(s);
        }
    </script>
</body>
</html>